package com.kzy.demoadmin.web.exception;
 
/**
 * Description:
 * 公共异常封装类
 * 用于在逻辑代码中抛出异常时的封装
 *
 * @author houyi
 * @version 1.0
 * @date 2020/1/22 15:44
 * @since JDK 1.8
 */
public class BizException extends RuntimeException implements CommonException{
 
    private int exCode;
 
    private String exMsg;
 
    @Override
    public int getExceptionCode() {
        return exCode;
    }
 
    @Override
    public String getExceptionMsg() {
        return exMsg;
    }
 
    /**
     * 使用自定义的异常枚举类构造异常
     * @param exceptionEnum
     */
    public BizException(CommonException exceptionEnum){
 
        this.exCode = exceptionEnum.getExceptionCode();
        this.exMsg = exceptionEnum.getExceptionMsg();
    }
 
    public BizException(int exCode, String exMsg){
        this.exCode = exCode;
        this.exMsg = exMsg;
    }
 
    public BizException(int exCode){
        this.exCode = exCode;
        this.exMsg = "未知错误";
    }
 
    public BizException(String exMsg){
        this.exCode = 10001;
        this.exMsg = exMsg;
    }
}